package com.wosiliujing.learning.controller;

import com.wosiliujing.learning.annotation.SysLog;
import com.wosiliujing.learning.service.RemoteTokenService;
import com.wosiliujing.learning.util.R;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author: liujing
 * @date: 2019/5/19 18:48
 * @description:
 */
@RestController
@AllArgsConstructor
@RequestMapping("/token")
public class TokenController {

    private final RemoteTokenService remoteTokenService;

    /**
     * 分页数据
     * @param params
     * @return
     */
    @GetMapping("/page")
    public R page(@RequestParam Map<String, Object> params){
        return remoteTokenService.getTokenPage(params);
    }

    /**
     * 删除token
     * @param token
     * @return
     */
    @SysLog("删除token")
    @PreAuthorize("@pms.hasPermisssion('sys_token_del')")
    @DeleteMapping("/{token}")
    public R delete(@PathVariable String token){
        return remoteTokenService.deleteToken(token);
    }

}
